package com.example.springboot.mapper;

import com.example.springboot.entity.Supplier;
import com.example.springboot.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SupplierMapper {

    @Select("SELECT * from sys_supplier")
    List<Supplier> findAll();

    @Select("SELECT supplier_number from sys_supplier where id = #{id}")
    String findById(@Param("id")Integer id);

    @Insert("insert into sys_supplier(supplier_number,supplier_name,supplier_address,supplier_type,linkman,tel) " +
            "VALUES (#{supplierNumber},#{supplierName},#{supplierAddress},#{supplierType},#{linkman},#{tel});")
    int insert(Supplier supplier);

    int update(Supplier supplier);

    @Delete("delete from sys_supplier where id = #{id}")
    Integer deleteById(@Param("id")Integer id);

    @Select("select * from sys_supplier where supplier_name like concat('%',#{supplierName},'%') limit #{pageNum},#{pageSize}")
    List<Supplier> selectPage(Integer pageNum, Integer pageSize, String supplierName);

    @Select("select count(*) from sys_supplier where supplier_name like concat('%',#{supplierName},'%')")
    Integer selectTotal(String supplierName);
}
